package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.entity.Emp;
import com.gxa.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @Controller  表明此类是Controller类
 * @RequestMapping(value="",method=) 定义接口的URI信息
 * @ResponseBody 响应体，响应JSON数据
 * @RequestBody 接收体，接收JSON对象的数据
 * @Autowired 自动装配
 * @GetMapping()
 * @PostMapping()
 */
@Controller
@RequestMapping("/emp")
public class EmpController {

      @Autowired
      private EmpService empService;

      //添加雇员信息
      @RequestMapping(value = "/addEmp",method = RequestMethod.POST)
      @ResponseBody
      public R addEmp(@RequestBody Emp emp){
          return empService.addEmp(emp);//默认转发
      }
      //修改雇员信息
      @RequestMapping(value = "/updateEmp",method = RequestMethod.POST)
      @ResponseBody
      public R updateEmp(@RequestBody Emp emp){
            R r = empService.updateEmp(emp);
            return r;
      }


//      public R updateEmp(@RequestBody Emp emp){
//
//      }
      //删除雇员信息
      @RequestMapping(value = "/delEmp",method = RequestMethod.POST)
      @ResponseBody
      public R delEmp(Integer id){
            System.out.println(id);
            R r = empService.deleteEmp(id);
            return r;
      }
      //查询雇员信息
      @RequestMapping(value = "/findEmp",method = RequestMethod.POST)
      @ResponseBody
      public R findEmp(int id){


            R r = empService.select(id);
            return r;
      }
      //.......

}
